# make html-version of this manual with:
# rmarkdown::render("5_alignment_moon.R")

# ====================================

# load libraries
library(qlcVisualize)
library(qlcData)
library(maptools)

# load ad-hoc functions
source("../../code/mappingAlignments.R")

# load doculects
places <- read.delim("../../data/places.tsv", quote = "")

# load voronoi diagram
load("../../data/voronoi.Rdata")

# ====================================

# show cognate sets of 'split' version
plot_cognates("../data/5_aligned_split.tsv")

# show corrected data of alignment
# with speculative *MVNSVC reconstruction
data <- "../data/5_aligned_lump.tsv"
plot_cognates(data)

# ====================================

# N in mond
plot_column(get_column(data, 2, 3))
title("Correspondences of 'N' in 'mond'")

# the 'n' in polish should probably be linked to this one, via metathesis
# MONS > MESON
N1 <- get_column(data,2,3)
N2 <- get_column(data,2,8)
N <- merge_columns(N1, N2) 
plot_column(N)
title("Correspondences of 'N' in 'mond'")

# S in mond
plot_column(get_column(data, 2, 5))
title("Correspondences of 'S' in 'mond'")

# T/C in mond
plot_column(get_column(data, 2, 9))
title("Correspondences of T in 'mond'")

# =========

# Vowels
plot_column(get_column(data, 2, 2))
title("Correspondences of first vowel")

plot_column(get_column(data, 2, 4))
title("Correspondences of second vowel")

plot_column(get_column(data, 2, 7))
title("Correspondences of third vowel")

# =========

# L in lune
plot_column(get_column(data, 5, 1))
title("Correspondences of 'L' in 'lune'")

# U in lune
plot_column(get_column(data, 5, 2))
title("Correspondences of 'U' in 'lune'")

# E in lune
plot_column(get_column(data, 5, 4))
title("Correspondences of 'E' in 'lune'")

# =========

# show Session Info
sessionInfo()
## R version 3.2.3 (2015-12-10)
## Platform: x86_64-apple-darwin13.4.0 (64-bit)
## Running under: OS X 10.11.5 (El Capitan)
## 
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] maptools_0.8-37    sp_1.2-1           qlcData_0.1.0     
## [4] qlcVisualize_0.1.0
## 
## loaded via a namespace (and not attached):
##  [1] gtools_3.5.0       spam_1.3-0         slam_0.1-32       
##  [4] lattice_0.20-33    colorspace_1.2-6   mapplots_1.5      
##  [7] htmltools_0.3      yaml_2.1.13        mgcv_1.8-10       
## [10] alphahull_2.0      spatstat_1.44-1    foreign_0.8-66    
## [13] registry_0.3       sgeostat_1.0-26    foreach_1.4.3     
## [16] plyr_1.8.3         stringr_1.0.0      fields_8.3-6      
## [19] munsell_0.4.2      gtable_0.1.2       raster_2.5-2      
## [22] caTools_1.17.1     evaluate_0.8       codetools_0.2-14  
## [25] knitr_1.12         httpuv_1.3.3       seriation_1.1-3   
## [28] Rcpp_0.12.3        xtable_1.8-0       KernSmooth_2.23-15
## [31] tensor_1.5         formatR_1.2.1      scales_0.3.0      
## [34] gdata_2.17.0       abind_1.4-3        mime_0.4          
## [37] deldir_0.1-9       mapdata_2.2-6      gplots_2.17.0     
## [40] tripack_1.3-7      ggplot2_2.0.0      digest_0.6.9      
## [43] stringi_1.0-1      gclus_1.3.1        qlcMatrix_0.9.5   
## [46] shiny_0.13.0       splancs_2.01-38    polyclip_1.3-2    
## [49] grid_3.2.3         tools_3.2.3        bitops_1.0-6      
## [52] magrittr_1.5       maps_3.0.2         goftest_1.0-3     
## [55] cluster_2.0.3      docopt_0.4.5       MASS_7.3-45       
## [58] Matrix_1.2-3       rmarkdown_0.9.2    iterators_1.0.8   
## [61] R6_2.1.1           TSP_1.1-3          nlme_3.1-122